Skip to content

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Jul 4, 2025

Recreate roles on existing databases in case when an external backup is being restored within the charm.

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

@dragomirp dragomirp changed the title [DPE-7678 ]recreate predefined roles [DPE-7678] recreate predefined roles Jul 4, 2025
@dragomirp dragomirp added the bug Something isn't working as expected label Jul 4, 2025
@dragomirp dragomirp changed the base branch from main to 16/edge July 4, 2025 14:37
@dragomirp dragomirp force-pushed the dpe-7678-recreate-predefined-roles branch from faad5af to 149fa04 Compare July 4, 2025 14:38
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.28%. Comparing base (a179e9d) to head (aa02f52).
⚠️ Report is 79 commits behind head on 16/edge.

Additional details and impacted files
@@           Coverage Diff            @@
##           16/edge    #1017   +/-   ##
========================================
  Coverage    70.28%   70.28%           
========================================
  Files           16       16           
  Lines         3806     3806           
  Branches       545      545           
========================================
  Hits          2675     2675           
  Misses        1001     1001           
  Partials       130      130           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dragomirp dragomirp force-pushed the dpe-7678-recreate-predefined-roles branch from 24d19f7 to 5110adb Compare July 4, 2025 15:50
@dragomirp dragomirp force-pushed the dpe-7678-recreate-predefined-roles branch 2 times, most recently from 4c7a411 to 9e8929e Compare July 5, 2025 01:33
@dragomirp dragomirp force-pushed the dpe-7678-recreate-predefined-roles branch from 9e8929e to baf3220 Compare July 5, 2025 01:34
@taurus-forever
Copy link
Contributor

taurus-forever commented Jul 6, 2025

It is almost perfect! I do not see:

  • pgaudit extention (\dx) enabled for all databases. Expected for all DBs.
  • pgaudit events pgaudit_ddl_command_end+pgaudit_sql_drop (\dy) are enabled for data-integrator related DB only (same as extention?). Expected for all DBs.
  • pgaudit events pgaudit_ddl_command_end + pgaudit_sql_drop (\d) are enabled for data-integrator related DB only (same as extention?). Expected for all DBs.

Other parts looks perfect!!!

)

await ops_test.model.wait_for_idle(status="active", timeout=1500)
await ops_test.model.wait_for_idle(status="active", timeout=1800)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failed with timeouts consistently in a previous run: https://github.com/canonical/postgresql-operator/actions/runs/16083228579

Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested with LB DB, it doesn the job, but pgaudit will have to follow as separate PR.

connection = None
try:
for database in ["postgres", "template1"]:
for database in self._get_existing_databases():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the loop in set_up_database and passing a cursor made the plugin test fail consistently: https://github.com/canonical/postgresql-operator/actions/runs/16081464233/job/45386910548

unit-postgresql-0: 22:27:52 ERROR unit.postgresql/0.juju-log __main__:Failed to disable plugin: cannot drop table pg_hba because extension orafce requires it
HINT:  You can drop extension orafce instead.
CONTEXT:  SQL statement "DROP TABLE IF EXISTS pg_hba"
PL/pgSQL function update_pg_hba() line 13 at SQL statement
SQL statement "CREATE SCHEMA tiger_data"
PL/pgSQL function inline_code_block line 4 at SQL statement

Leaving the separate loops be for now.

@dragomirp dragomirp marked this pull request as ready for review July 7, 2025 11:01
@dragomirp dragomirp merged commit c8a49ae into 16/edge Jul 8, 2025
220 of 230 checks passed
@dragomirp dragomirp deleted the dpe-7678-recreate-predefined-roles branch July 8, 2025 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants